# -*- coding: utf-8 -*-
from flask import request
from flask import Blueprint
from common.flaskResponse import successResp, errorResp
from service import reinterpolate
from service.regular import regularAICombinationStrategy
from service.regular import regularAISeason
import json

regular = Blueprint('regular', __name__)

@regular.route('/interpolateWarrantyByWeek', methods=['POST'])
def interpolation():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode("utf-8"))
        interpolatate_class = reinterpolate.reinterpolate()
        result = interpolatate_class.interpolate(json_data)
    return successResp(result)


@regular.route('/regularAICombinationStrategy', methods=['POST'])
def aiCombinationStrategy():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode("utf-8"))
        combinationStrategyPred_class = regularAICombinationStrategy.regularAICombinationStrategy()
        result = combinationStrategyPred_class.shortfstbypn(json_data)
    return successResp(result)


@regular.route('/regularAISeason', methods=['POST'])
def aiSeason():
    if request.method == 'POST':
        data = request.get_data()
        json_data = json.loads(data.decode("utf-8"))
        aiSeasonPred_class = regularAISeason.regularAISeason()
        result = aiSeasonPred_class.shortfstbypn(json_data)
    return successResp(result)
